#include<iostream>

namespace my_mutex
{
    class mutex
    {
    public:
        mutex()
        {
            ::pthread_mutex_init(&_mutex, NULL);  
        }
        ~mutex()
        {
            ::pthread_mutex_destroy(&_mutex);
        }
        void lock()
        {
            pthread_mutex_lock(&_mutex);
        }

        void unlock()
        {
            pthread_mutex_unlock(&_mutex);
        }
    private:
        pthread_mutex_t _mutex; 
    };


    class my_lock
    {
    public:
        my_lock(mutex & mutex):_metux(mutex)
        {
            _metux.lock();
        }
        ~my_lock()
        {
           _metux.unlock();
        }
    private:
        mutex& _metux;
    };



};
